package org.database.service.impl;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.database.attribute.YmlStorageAttribute;
import org.database.service.StorageAbstract;
import org.database.utils.GM4Utils;

/**
 * YmlStorage
 *
 * @author grl
 * @date 2024/1/9
 */
@Slf4j
@RequiredArgsConstructor
public class YmlStorage implements StorageAbstract {

    private final YmlStorageAttribute storageAttribute;

    @Override
    public String encrypt(Object obj, String storageField) {
        String encSecret = storageAttribute.getEncSecret();
       return GM4Utils.encryptEcb(storageField,encSecret);
    }

    @Override
    public String decrypt(Object obj, String storageField) {
        String decSecret = storageAttribute.getDecSecret();
        return GM4Utils.decryptEcb(storageField,decSecret);
    }
}
